package com.project.service;

import com.project.dao.DepartmentMapper;
import com.project.entity.Department;
import com.project.service.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(rollbackFor = Exception.class)
@Service
public class DepartmentServiceImpl extends BaseService implements DepartmentService{

    @Autowired
    DepartmentMapper departmentMapper;

    @Override
    public void add(Department department) {
        departmentMapper.insertSelective(department);
    }

    @Override
    public List<Department> findByCondition(Department department) {
        return departmentMapper.selectByCondition(department);
    }

    @Override
    public List<Department> findBySchoolid(Integer schoolid) {
        return departmentMapper.selectBySchoolid(schoolid);
    }

    @Override
    public Department findById(Integer id) {
        return departmentMapper.selectByPrimaryKey(id);
    }
}
